package com.xscha.soyue.common.core.mapper.converter;

import com.xscha.soyue.common.core.exception.status.SoyStatusCode;
import com.xscha.soyue.common.core.exception.status.StatusCode;
import ma.glasnost.orika.CustomConverter;
import ma.glasnost.orika.MappingContext;
import ma.glasnost.orika.metadata.Type;

import java.util.Objects;

/**
 * 解决interface转换的问题
 *
 * @author Vondser
 * @version V2024.1.0
 */
public class SoyStatusCodeConverter extends CustomConverter<SoyStatusCode, StatusCode> {

	@Override
	public StatusCode convert(SoyStatusCode source, Type<? extends StatusCode> destinationType,
			MappingContext mappingContext) {
		return Objects.isNull(source) ? null : new StatusCode(source.getCode(), source.getMessage());
	}

}
